package com.sh.common.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum TransferFlagEnum {

    /**
     * 转出
     */
    TRANSFER_OUT(-1, "转出"),

    /**
     * 转入
     */
    TRANSFER_IN(1, "转入"),

    ;

    private final Integer code;
    private final String info;

    public static TransferFlagEnum of(Integer code) {
        Objects.requireNonNull(code, "类型不存在系统");
        return Stream.of(values()).filter(item -> item.code.equals(code))
            .findAny()
            .orElseThrow(() -> new IllegalArgumentException(
                String.format("%s%s", code, "类型不存在系统")
            ));
    }
}
